/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.ipleiria.plp.ui;

import de.enough.polish.ui.Command;
import de.enough.polish.ui.CommandListener;
import de.enough.polish.ui.Displayable;
import de.enough.polish.ui.List;
import de.enough.polish.util.Locale;
/**
 *
 * @author Filipe
 */
public class AdicionarFotografia extends List implements CommandListener {

    private Command cmdOK = new Command(Locale.get("cmd.OK"), Command.CANCEL, 1);
    private Command cmdCanc = new Command(Locale.get("cmd.Cancelar"), Command.EXIT, 2);
    private EventoScreen screen;

    public AdicionarFotografia(EventoScreen screen) {
        //#style defaultScreen
        super(Locale.get("title.AdicionarImagem"), List.IMPLICIT);
        this.screen = screen;
        this.setCommandListener(this);
        this.setSelectCommand(cmdOK);
        this.addCommand(cmdOK);
        this.addCommand(cmdCanc);
        //#style itemInput
        this.append(Locale.get("foto.exist"), null);
        //#if polish.api.mmapi
        //#style itemInput
        this.append(Locale.get("foto.newf"), null);
        //#endif
    }

    public void commandAction(Command c, Displayable d) {

        if (c == cmdOK) {
            if (this.getSelectedIndex() == 0) {
                PhotoBrowser pb = new PhotoBrowser(screen);
                screen.getMidlet().getDisplay().setCurrent(pb);
            }
            //#if polish.api.mmapi
            else if (this.getSelectedIndex() == 1) {
                TirarFotoScreen tfs = new TirarFotoScreen(screen);
            }
            //#endif
        } else if (c == cmdCanc) {
            screen.returnFromPhoto(null);
        }

    }
}
